package com.jic.manager.impl;

import java.lang.Long;
import java.util.List;

import com.jic.manager.entity.SysUserDept;
import com.jic.manager.mapper.SysUserDeptMapper;
import com.jic.manager.service.SysUserDeptService;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.Page;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 用户数据权限关联表
 * @author : 
 * @email : 
 * @since : 2020-03-25 01:21:40
 * @version : v1.0.0
 */
@Service
public class SysUserDeptServiceImpl implements SysUserDeptService{

    @Resource
    private SysUserDeptMapper sysUserDeptMapper;

    @Override
    public long insert(SysUserDept sysUserDept) {
        long flag = sysUserDeptMapper.insert(sysUserDept);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return sysUserDeptMapper.delete(id);
    }

    @Override
    public long update(SysUserDept sysUserDept) {
        return sysUserDeptMapper.update(sysUserDept);
    }

    @Override
    public SysUserDept queryByPrimaryKey(Long id){
        return sysUserDeptMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<SysUserDept> query(SysUserDept sysUserDept){
        return sysUserDeptMapper.query(sysUserDept);
    }

    @Override
    public PageResult<SysUserDept> queryPage(SysUserDept sysUserDept, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<SysUserDept> list = sysUserDeptMapper.queryPage(startIndex, pageQuery.getLimit(), sysUserDept);
        long count = sysUserDeptMapper.queryPageCount(sysUserDept);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}